package io.renren.modules.app.service.user.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.modules.app.dao.user.UserExperienceDao;
import io.renren.modules.app.entity.user.UserExperienceEntity;
import io.renren.modules.app.service.user.UserExperienceService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;


@Service("UserExperienceService")
@RequiredArgsConstructor
public class UserExperienceServiceImpl extends ServiceImpl<UserExperienceDao, UserExperienceEntity> implements UserExperienceService {

    private final UserExperienceDao userExperienceDao;

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<UserExperienceEntity> page = this.page(
                new Query<UserExperienceEntity>().getPage(params),
                new QueryWrapper<UserExperienceEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public UserExperienceEntity getByResumeId(Integer resumeId) {

        LambdaQueryWrapper<UserExperienceEntity> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(UserExperienceEntity::getResumeId,resumeId);
        return this.getOne(wrapper);
    }

    @Override
    public List<UserExperienceEntity> getListByUserId(Integer resumeId) {
        return userExperienceDao.selectList(new LambdaQueryWrapper<UserExperienceEntity>()
                .eq(UserExperienceEntity::getResumeId, resumeId));
    }

}